package com.xgq.drink.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.xgq.drink.entity.DiscountInfo;
import com.xgq.drink.entity.R;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 优惠信息表 服务类
 * </p>
 *
 * @author xgq
 * @since 2025-03-04
 */
public interface IDiscountInfoService extends IService<DiscountInfo> {
    
    // 创建优惠券
    R createDiscountInfo(DiscountInfo discountInfo);
    // 根据产品ID查询优惠券
    List<DiscountInfo> getDiscountsByProductId(Long productId);
    // 更新优惠券

    @Transactional(rollbackFor = Exception.class)
    R updateDiscountInfo(DiscountInfo discountInfo);

    // 下架优惠券（修改状态）
    R deactivateDiscountInfo(Long discountId);

    @Transactional(rollbackFor = Exception.class)
    R deactivateDiscountInfo2(Long discountId);

    // 补充优惠券数量
    R replenishDiscountInfo(Long discountId, Integer maxUserClaims);
    
    // 分页查询优惠券
    R getDiscountInfos(String discountType, Long shopId, Long productId, Integer page, Integer size);
    
    // 获取优惠券详情
    R getDiscountInfo(Long discountId);
    
    // 用户领取优惠券
    R claimDiscountInfo(Long discountId);

    DiscountInfo getDiscountInfoById(Long discountId);
}
